<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        body {
            margin: 0;
            background-image: url("imgs/scbjtp1.jpg");
            background-size: cover; /*设置封面尺寸*/
            text-align: center;
        }
        h1{
            font-size: 72px;
            color: #0096dc;
            margin-bottom: 0;
        }
        img{
            width: 100px;
        }
        h2{
            font-size: 32px;
            color: #0096dc;
            margin: 0;
        }
    </style>
</head>
<body>
<div id="app">
    <h1>欢迎来到书城</h1>
    <img src="imgs/scbjtp2.jpg" alt="">
    <h2>ShuCheng</h2>
    <el-card>
        <el-form>
            <el-form-item label="用户名">
                <el-input type="text" v-model="user.name" placeholder="请输入用户名"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="user.pwd" placeholder="请输入密码"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button @click="login()">登录</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
      data:{
          user:{
              name:"",
              pwd:""
          },
          return :{

          }
      },
    methods:{
        login(){
            axios.post("/login",v.user).then(function (response) {
                if (response.data==0){
                    location.href="/admin.html";
                }else if(response.data==2){
                    location.href="/detail.html";
                }else {
                    alert("用户名不存在或密码错误！")
                }
            })
        }
    }
  })
</script>
</html>